// Node 脚本：测试 helpers 统一入口及 auth_middleware require
const path = require('path');

try {
  // 1. require helpers 统一入口
  const helpersPath = path.resolve(__dirname, '../../my_user/helpers/index.js');
  const helpers = require(helpersPath);
  console.log('[测试通过] helpers/index.js 加载成功:', Object.keys(helpers));

  // 2. require auth_middleware
  if (!helpers.authMiddleware) {
    throw new Error('helpers.index.js 未导出 authMiddleware');
  }
  console.log('[测试通过] authMiddleware 加载成功:', Object.keys(helpers.authMiddleware));

  // 3. 检查 checkAuth 方法
  if (typeof helpers.authMiddleware.checkAuth !== 'function') {
    throw new Error('authMiddleware 未导出 checkAuth 方法');
  }
  console.log('[测试通过] checkAuth 方法存在');

} catch (err) {
  console.error('[测试失败]', err);
  process.exit(1);
}

console.log('helpers require 路径测试完成'); 